package settings.intercepts;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class loginedCheck implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(request.getRequestURI().contains("login")||request.getRequestURI().contains("Login")||request.getSession().getAttribute("userMessage")!=null){
            return true;
        }else {
            response.sendRedirect(request.getContextPath()+"/static/login.jsp");
            return false;
        }
    }
}
